﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FirstFloor.Documents.Pdf.ColorSpaces
{
    /// <summary>
    /// Represents the DeviceRGB color space.
    /// </summary>
    internal class DeviceRGB
        : CalRGB
    {
        private static DeviceRGB @default = new DeviceRGB();

        private DeviceRGB()
        {
            this.Name = "DeviceRGB";
        }

        /// <summary>
        /// Gets the DeviceRGB color space.
        /// </summary>
        /// <value>The default.</value>
        public static DeviceRGB Default
        {
            get { return @default; }
        }

        /// <summary>
        /// Converts the value from specified color space to a color in the DeviceRGB color space.
        /// </summary>
        /// <param name="colorSpace">The color space.</param>
        /// <param name="values">The values.</param>
        /// <returns></returns>
        public Color ToColor(ColorSpace colorSpace, params double[] values)
        {
            var rgb = values;

            if (!(colorSpace is CalRGB)) {
                rgb = this.FromXYZ(colorSpace.ToXYZ(values));
            }
            return Color.FromArgb(0xff, (byte)(rgb[0] * 0xff), (byte)(rgb[1] * 0xff), (byte)(rgb[2] * 0xff));
        }
    }
}
